#include"head.h"
int connection(int *fd){
    *fd=socket(AF_INET,SOCK_STREAM,0);

    char port[10] = {0};
    char ip[20] = {0};
    char port1[] = "port";
    char ip1[] = "ip";
    // 调用配置文件获取信息
    int ret = getparameter(port1, port);
    ERROR_CHECK(ret, -1, "getparameter");
    getparameter(ip1, ip);

    struct sockaddr_in sockaddr;
    sockaddr.sin_family=AF_INET;
    sockaddr.sin_addr.s_addr=inet_addr(ip);
    sockaddr.sin_port=htons(atoi(port));
    connect(*fd,(struct sockaddr*)&sockaddr,sizeof(sockaddr));
    printf("连接成功\n");

    return 0;
}
